#ifndef __MEMLAYOUT_H__
#define __MEMLAYOUT_H__

// Physical memory layout

// qemu -m 128M
#define PHYSTOP 0x88000000 // Physical memory ends at 128MB
#define KERNBASE 0x80000000 // Kernel base address

// Device memory map
#define UART0 0x10000000L
#define VIRTIO0 0x10008000L  // virtio mmio 设备地址

// CLINT (Core Local Interruptor) for timer
#define CLINT_BASE         0x02000000UL
#define CLINT_MSIP(hart)   (CLINT_BASE + 0x0000 + 4*(hart))
#define CLINT_MTIMECMP(h)  (CLINT_BASE + 0x4000 + 8*(h))
#define CLINT_MTIME        (CLINT_BASE + 0xBFF8)

// 便于取地址（指针用）
#define CLINT_MTIMECMP_ADDR(h) (CLINT_MTIMECMP(h))
#define CLINT_MTIME_ADDR       (CLINT_MTIME)


#endif // __MEMLAYOUT_H__